package com.uflower.product.controller;

import com.uflower.product.service.SpuInfoService;
import com.uflower.product.vo.ProductDetailVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/product")
public class PageController {
    @Autowired
    SpuInfoService spuInfoService;

    @RequestMapping("/cartList")
    public String CartList(){
        System.out.println("hello");
        return "cartList";
    }
    @RequestMapping("/search")
    public String searchPage(){
        System.out.println("hello");
        return "search";
    }
    @RequestMapping("/productDetail")
    public String productDetail(@RequestParam("skuId") Long skuId, Model model){
        System.out.println("productDetail");
        ProductDetailVo productDetailVo = spuInfoService.getProductDetailVo(skuId);
        model.addAttribute("product",productDetailVo);
        return "item";
    }
    //主页
    @RequestMapping("/index")
    public String mainIndex(){
        //ProductDetailVo productDetailVo = spuInfoService.getProductDetailVo(19L);
        return "index";
    }
    @ResponseBody
    @RequestMapping("/test")
    public ProductDetailVo test(){
        ProductDetailVo productDetailVo = spuInfoService.getProductDetailVo(19L);
        return productDetailVo;
    }

}
